package com.atguigu.yygh.user.controller.admin;

import com.atguigu.yygh.model.user.UserInfo;
import com.atguigu.yygh.result.R;
import com.atguigu.yygh.user.service.UserInfoService;
import com.atguigu.yygh.vo.user.UserInfoQueryVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/*==========================================
      时 间:   2022-04-26
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
 ==========================================*/
@RestController
@RequestMapping("/admin/userinfo")
public class AdminUserInfoController {

    @Autowired
    private UserInfoService userInfoService;


    //认证审批
    @GetMapping("approval/{userId}/{authStatus}")
    public R approval(@PathVariable Long userId,@PathVariable Integer authStatus) {
        userInfoService.approval(userId,authStatus);
        return R.ok();
    }


    @GetMapping("/show/{id}")
    public R getUserInfoAndPatientList(@PathVariable Integer id){
        Map<String,Object> map= userInfoService.getUserInfoAndPatientList(id);
        return R.ok().data(map);
    }


    @GetMapping("/{page}/{limit}")
    public R getUserPageByCondition(@PathVariable Integer page,
                                    @PathVariable Integer limit,
                                    UserInfoQueryVo userInfoQueryVo){

       Page<UserInfo> result= userInfoService.getUserPageByCondition(page,limit,userInfoQueryVo);

       return R.ok().data("page",result);
    }
    ///status/${id}/${status}
    @PutMapping("/status/{id}/{status}")
    public R updateStatus(@PathVariable Long id,
                                    @PathVariable Integer status){

        userInfoService.updateStatus(id,status);
        return R.ok();
    }

}
